<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Node.pb</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font><font color="#3A3966">;   PureBasic - Node
</font><font color="#3A3966">;
</font><font color="#3A3966">;    (c) Fantaisie Software
</font><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font>
<b><font color="#3A3966">IncludeFile</font></b> <font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Screen3DRequester.pb"

<font color="#924B72">#CameraSpeed</font> = 1
<font color="#924B72">#NBNode</font>      = 3
<font color="#924B72">#NbBranche</font>   = 7

<b><font color="#3A3966">Define</font></b>.l i, j
<b><font color="#3A3966">Define</font></b>.f KeyX, KeyY, MouseX, MouseY

<b><font color="#3A3966">Dim</font></b> <font color="#3A3966">entity</font>(<font color="#924B72">#NbBranche</font>, <font color="#924B72">#NBNode</font>)
<b><font color="#3A3966">Dim</font></b> <font color="#3A3966">Node</font>(<font color="#924B72">#NbBranche</font>, <font color="#924B72">#NBNode</font>)


<b><font color="#3A3966">If</font></b> <font color="#3A3966">InitEngine3D</font>()
  
<font color="#3A3966">  Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data"                 , <font color="#924B72">#PB_3DArchive_FileSystem</font>)
<font color="#3A3966">  Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data/Textures"        , <font color="#924B72">#PB_3DArchive_FileSystem</font>)
<font color="#3A3966">  Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data/Packs/skybox.zip", <font color="#924B72">#PB_3DArchive_Zip</font>)
  
<font color="#3A3966">  InitSprite</font>()
<font color="#3A3966">  InitKeyboard</font>()
<font color="#3A3966">  InitMouse</font>()
  
  <b><font color="#3A3966">If</font></b> <font color="#3A3966">Screen3DRequester</font>()
    
<font color="#3A3966">    CreateMaterial</font>(0,<font color="#3A3966"> LoadTexture</font>(0, "Dirt.jpg"))
    
<font color="#3A3966">    CreateSphere</font>(0, 1)
    
    d=3
    
    <b><font color="#3A3966">For</font></b> j = 0 <b><font color="#3A3966">To</font></b> <font color="#924B72">#NbBranche</font>
      
<font color="#3A3966">      Node</font>(j, 0) =<font color="#3A3966"> CreateNode</font>(<font color="#924B72">#PB_Any</font>, 0, 0, 0)
<font color="#3A3966">      Entity</font>(j, 0) =<font color="#3A3966"> CreateEntity</font>(<font color="#924B72">#PB_Any</font>,<font color="#3A3966"> MeshID</font>(0),<font color="#3A3966"> MaterialID</font>(0))
<font color="#3A3966">      ScaleEntity</font>(<font color="#3A3966">Entity</font>(j, 0), 1, 1, 2)       
<font color="#3A3966">      AttachNodeObject</font>(<font color="#3A3966">Node</font>(j, 0),<font color="#3A3966"> EntityID</font>(<font color="#3A3966">Entity</font>(j, 0)))
<font color="#3A3966">      MoveEntity</font>(<font color="#3A3966">entity</font>(j, 0), 0, 0, d)
      
      <b><font color="#3A3966">For</font></b> i = 1 <b><font color="#3A3966">To</font></b> <font color="#924B72">#NBNode</font>
<font color="#3A3966">        Node</font>(j, i) =<font color="#3A3966"> CreateNode</font>(<font color="#924B72">#PB_Any</font>,0,0,0)
<font color="#3A3966">        MoveNode</font>(<font color="#3A3966">Node</font>(j, i), 0, 0, d)
<font color="#3A3966">        AttachNodeObject</font>(<font color="#3A3966">Node</font>(j, i - 1),<font color="#3A3966"> NodeID</font>(<font color="#3A3966">Node</font>(j, i)))
<font color="#3A3966">        entity</font>(j, i) =<font color="#3A3966"> CreateEntity</font>(<font color="#924B72">#PB_Any</font>,<font color="#3A3966"> MeshID</font>(0),<font color="#3A3966"> MaterialID</font>(0))
<font color="#3A3966">        ScaleEntity</font>(<font color="#3A3966">Entity</font>(j, i), 1, 1, 2)   
<font color="#3A3966">        AttachNodeObject</font>(<font color="#3A3966">Node</font>(j, i),<font color="#3A3966"> EntityID</font>(<font color="#3A3966">Entity</font>(j, i)))
<font color="#3A3966">        MoveEntity</font>(<font color="#3A3966">entity</font>(j, i), 0, 0, d)
      <b><font color="#3A3966">Next</font></b>
      
    <b><font color="#3A3966">Next</font></b>
    
    <font color="#3A3966">;-Camera 
</font><font color="#3A3966">    CreateCamera</font>(0, 0, 0, 100, 100)
<font color="#3A3966">    MoveCamera</font>(0, 0, 30, 30, <font color="#924B72">#PB_Absolute</font>)
<font color="#3A3966">    CameraLookAt</font>(0,<font color="#3A3966">NodeX</font>(<font color="#3A3966">Node</font>(0, 0)),<font color="#3A3966"> NodeY</font>(<font color="#3A3966">Node</font>(0, 0)),<font color="#3A3966"> NodeZ</font>(<font color="#3A3966">Node</font>(0, 0)))
    
    <font color="#3A3966">;-Skybox
</font><font color="#3A3966">    SkyBox</font>("stevecube.jpg")
    
    <font color="#3A3966">;-Light
</font><font color="#3A3966">    CreateLight</font>(0,<font color="#3A3966"> RGB</font>(255, 255, 255), 0, 500, 100)
<font color="#3A3966">    AmbientColor</font>(<font color="#3A3966">RGB</font>(85, 85, 85))
     

    <b><font color="#3A3966">Repeat</font></b>
      
<font color="#3A3966">      Screen3DEvents</font>()
      
      <b><font color="#3A3966">If</font></b>  <font color="#3A3966">ExamineMouse</font>()
        
        <b><font color="#3A3966">For</font></b> j = 0 <b><font color="#3A3966">To</font></b> <font color="#924B72">#NbBranche</font>
<font color="#3A3966">          RotateNode</font>(<font color="#3A3966">Node</font>(j, 0), (45-(<font color="#3A3966">MouseY</font>()/8)), 360.0/(<font color="#924B72">#NbBranche</font>+1) * j + (<font color="#3A3966">MouseX</font>()/2),0, <font color="#924B72">#PB_Absolute</font>)
          <b><font color="#3A3966">For</font></b> i = 1 <b><font color="#3A3966">To</font></b> <font color="#924B72">#NBNode</font>
<font color="#3A3966">            RotateNode</font>(<font color="#3A3966">Node</font>(j, i), 45-(<font color="#3A3966">MouseY</font>()/8), 0, 0, <font color="#924B72">#PB_Absolute</font>)
          <b><font color="#3A3966">Next</font></b>
        <b><font color="#3A3966">Next</font></b>
        
      <b><font color="#3A3966">EndIf</font></b>
      
      <b><font color="#3A3966">If</font></b> <font color="#3A3966">ExamineKeyboard</font>()
        
        <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Up</font>)
<font color="#3A3966">          MoveCamera</font>(0, 0, 0, -<font color="#924B72">#CameraSpeed</font>)
        <b><font color="#3A3966">ElseIf</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Down</font>)
<font color="#3A3966">          MoveCamera</font>(0, 0, 0, <font color="#924B72">#CameraSpeed</font>)
        <b><font color="#3A3966">EndIf</font></b>
        
        <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Left</font>)
<font color="#3A3966">          MoveCamera</font>(0, <font color="#924B72">#CameraSpeed</font>, 0, 0)
        <b><font color="#3A3966">ElseIf</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Right</font>)
<font color="#3A3966">          MoveCamera</font>(0, -<font color="#924B72">#CameraSpeed</font>, 0, 0)
        <b><font color="#3A3966">EndIf</font></b>
        
      <b><font color="#3A3966">EndIf</font></b>
                
<font color="#3A3966">      RenderWorld</font>()
<font color="#3A3966">      Screen3DStats</font>()
<font color="#3A3966">      FlipBuffers</font>()
    <b><font color="#3A3966">Until</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Escape</font>) <b><font color="#3A3966">Or</font></b> Quit = 1
  <b><font color="#3A3966">EndIf</font></b>
  
<b><font color="#3A3966">Else</font></b>
<font color="#3A3966">  MessageRequester</font>("Error", "The 3D Engine can't be initialized", 0)
<b><font color="#3A3966">EndIf</font></b>

<b><font color="#3A3966">End</font></b></font></pre>
</body></html>
